package com.demo.controller_admin;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.demo.dao_admin.LecturerDAO;
import com.demo.entity.LecturerData;
import com.demo.entity.ResponseLayui;
import com.demo.entity.ResponseResult;
import com.demo.service_admin.LecturerService;

@Controller("adminLecturerController")
@RequestMapping(value = "/${site.adminUrlPrefix}/lecturer")
public class LecturerController extends BaseController {
	@Autowired
	LecturerDAO lecturerDAO;
	
	@Resource(name = "adminLecturerService")
	LecturerService lecturerService;

	@GetMapping(value = "/list")
	public String list() {
		return adminTemplatePrefix + "/lecturer_list";
	}
	
	@GetMapping(value = "/list_json")
	public @ResponseBody ResponseResult<List<LecturerData>> list_json(Integer page, LecturerData lecturer) {
		Page<LecturerData> data = lecturerService.findAll(lecturer, getPageable(page));
		return new ResponseLayui<List<LecturerData>>(data.getTotalElements(), data.getContent());
	}


	
}